from random_walk import RandomWalk
from plotly.graph_objs import Bar,Layout
from plotly import offline

wk = RandomWalk(80)
wk.fill_walk()

print(f'{wk.x_values}, {wk.y_values}')


# 分析结果
results = [wk.x_values[index] + wk.y_values[index] for index in range(0, wk.num_points)]
print(f'漫步结果={results}')

# 展示结果集
x_values = list(range(1, wk.num_points+1))
data = [Bar(x=x_values, y=results)]

# 展示效果
x_axis_config = {'title': '每次漫步大小', 'dtick': 1}
y_axis_config = {'title': '漫步次数'}

my_layout = Layout(title='随机漫步', xaxis= x_axis_config, yaxis= y_axis_config)

# 绘制展示
offline.plot({'data': data, 'layout': my_layout}, filename='d6.html')
